package com.xianbeiying.app.ckgl.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.nostra13.universalimageloader.core.ImageLoader;
import com.xianbeiying.app.ckgl.R;
import com.xianbeiying.app.ckgl.bean.CropsBean;

import java.util.List;

/**
 * 农作物数据适配
 */
public class EdUpContentdapter extends BaseAdapter {
    private Context context;
    private List<CropsBean.VBean.ALLCROPSBean.CropssBean> crops;
    private String title;
    public EdUpContentdapter(Context context, List<CropsBean.VBean.ALLCROPSBean.CropssBean> crops) {
        this.context = context;
        this.crops = crops;
    }

    public EdUpContentdapter(Context context, List<CropsBean.VBean.ALLCROPSBean.CropssBean> crops, String title) {
        this.context = context;
        this.crops = crops;
        this.title=title;
    }
    private ImageLoader imageLoader=ImageLoader.getInstance();
    @Override
    public int getCount() {
        return crops.size();
    }

    @Override
    public Object getItem(int position) {
        return getItem(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        final ViewHolder holder;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_edupgh, parent, false);
            holder = new ViewHolder();
            holder.tv_cainame = (TextView) convertView.findViewById(R.id.tv_edup_content);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
            holder.tv_cainame.setText(crops.get(position).getCropName());
        return convertView;
    }

    private class ViewHolder {
        TextView tv_cainame;
    }
}
